<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      v-for="item in showArr"
      :key="item.id"
      :class="{ completed: item.isDone }"
    >
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.isDone" />
        <label>{{ item.name }}</label>
        <button class="destroy" @click="delFn(item.id)"></button>
      </div>
    </li>
  </ul>
</template>

<script>
import { mapState, mapMutations, mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  methods: {
    ...mapMutations(["del"]),
    delFn(id) {
      this.del(id);
    },
  },
  computed: {
    ...mapState(["list"]),
    ...mapGetters(["showArr"]),
  },
};
</script>